package com.macro.mall.controller;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.service.JdyService;
import com.macro.mall.vo.JdyProductCategoryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "JdyController", description = "筋斗云")
@RequestMapping("/jdy")
public class JdyController {
    @Autowired
    private JdyService jdyService;
    @ApiOperation("查询商品类别")
    @GetMapping("/productCategory")
    public CommonResult<List<JdyProductCategoryVO>> productCategory(){
        return CommonResult.success(jdyService.productCategory());
    }
    @ApiOperation("查询商品")
    @GetMapping("/product")
    public CommonResult<Map<String,Object>> product(
            @RequestParam(value = "productNumber", required = false) String productNumber,
            @RequestParam(value = "categoryId", required = false) String categoryId,
            @RequestParam(value = "pageSize", required = false) Integer pageSize,
            @RequestParam(value = "page", required = false) Integer page
    ){
        return CommonResult.success(jdyService.productList(productNumber,categoryId,pageSize,page));
    }
}
